package org.lilred.ui;

import net.rim.device.api.ui.Graphics;

import org.lilred.ui.theme.Theme;

public class ThemedLabelField extends ThemedField {
	String labelText;
	int padding;

	public ThemedLabelField(String labelText, Theme unfocus, Theme focus, long style) {
		super(unfocus, focus, style);
		this.labelText = labelText;
		this.defaultTheme = unfocus;
		this.focusTheme = focus;
	}
	
	public ThemedLabelField(String labelText, Theme unfocus, Theme focus) {
		this(labelText, unfocus, focus, 0);
	}
	

	public ThemedLabelField(String labelText, int padding, Theme unfocus, Theme focus, long style) {
		super(unfocus, focus, style);
		this.padding = padding;
		this.labelText = labelText;
		this.defaultTheme = unfocus;
		this.focusTheme = focus;
	}
	
	public ThemedLabelField(String labelText, int padding, Theme unfocus, Theme focus) {
		this(labelText, padding, unfocus, focus, 0);
	}
	
	public int getPreferredWidth() {
		return getFont().getAdvance(labelText) + 2 * padding;
	}
	
	public int getPreferredHeight() {
		return getFont().getHeight() + 2 * padding;
	}
	
	protected void layout(int width, int height) {
		setExtent(width, getPreferredHeight());
	}
	
	protected void paint(Graphics g) {
		super.paint(g);
		g.drawText(labelText, padding, padding);
	}

	public Theme getActiveTheme() {
		// TODO Auto-generated method stub
		return null;
	}

}
